package com.ruoyi.examination.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.examination.util.SnowflakeIdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.examination.mapper.QuestionOptionMapper;
import com.ruoyi.examination.domain.QuestionOption;
import com.ruoyi.examination.service.IQuestionOptionService;

/**
 * 选择题选项Service业务层处理
 * 
 * @author hcc
 * @date 2025-10-21
 */
@Service
public class QuestionOptionServiceImpl implements IQuestionOptionService 
{
    @Autowired
    private QuestionOptionMapper questionOptionMapper;

    /**
     * 查询选择题选项
     * 
     * @param optionId 选择题选项主键
     * @return 选择题选项
     */
    @Override
    public QuestionOption selectQuestionOptionByOptionId(String optionId)
    {
        return questionOptionMapper.selectQuestionOptionByOptionId(optionId);
    }

    /**
     * 查询选择题选项列表
     * 
     * @param questionOption 选择题选项
     * @return 选择题选项
     */
    @Override
    public List<QuestionOption> selectQuestionOptionList(QuestionOption questionOption)
    {
        return questionOptionMapper.selectQuestionOptionList(questionOption);
    }

    /**
     * 新增选择题选项
     * 
     * @param questionOption 选择题选项
     * @return 结果
     */
    @Override
    public int insertQuestionOption(QuestionOption questionOption)
    {
        questionOption.setCreateBy(SecurityUtils.getUsername());
        questionOption.setQuestionId(String.valueOf(new SnowflakeIdUtils(5,8).nextId()));
        questionOption.setCreateTime(DateUtils.getNowDate());
        return questionOptionMapper.insertQuestionOption(questionOption);
    }

    /**
     * 修改选择题选项
     * 
     * @param questionOption 选择题选项
     * @return 结果
     */
    @Override
    public int updateQuestionOption(QuestionOption questionOption)
    {
        questionOption.setUpdateTime(DateUtils.getNowDate());
        return questionOptionMapper.updateQuestionOption(questionOption);
    }

    /**
     * 批量删除选择题选项
     * 
     * @param optionIds 需要删除的选择题选项主键
     * @return 结果
     */
    @Override
    public int deleteQuestionOptionByOptionIds(String[] optionIds)
    {
        return questionOptionMapper.deleteQuestionOptionByOptionIds(optionIds);
    }

    /**
     * 删除选择题选项信息
     * 
     * @param optionId 选择题选项主键
     * @return 结果
     */
    @Override
    public int deleteQuestionOptionByOptionId(String optionId)
    {
        return questionOptionMapper.deleteQuestionOptionByOptionId(optionId);
    }
}
